package com.ac.app.web.action.pick;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionMapping;

import com.caac.core.config.QueryClass;
import com.caac.core.util.Page;
import com.caac.core.web.action.BasePageViewAction;
import com.caac.core.web.action.BaseViewAction;
import com.caac.core.web.action.PageViewForward;
import com.caac.core.web.action.ViewForward;
import com.caac.core.web.form.BaseForm;
import com.ac.app.dm.PickCtntItemPar;
import com.ac.app.dm.PickEntry;
import com.ac.app.web.form.PkEntrySearchForm;
import com.ac.app.web.view.PkCtntItemParView;
import com.ac.app.web.view.PkEntryView;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: Copyright AgileCentury 2008
 * </p>
 * <p>
 * Company: AgileCentury
 * </p>
 * 
 * @author <a href="mailto:ac@agilecentury.com">Agile</a>
 * @version 1.0
 */

public class SearchPkCtntItemParAction extends BaseViewAction {
	private static final String VIEW_NAME = "pkCtntItemParView";
	private static final String ORDER_NAME = "pkCtntItemParOrder";
	
	protected ViewForward doViewExecute(ActionMapping mapping, BaseForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String pEntryId = request.getParameter("pEntryId");
		List dmList = getBaseManager().getObjects(PickCtntItemPar.class,
				"pick_Entry = '" + pEntryId + "'",getOrder(ORDER_NAME));

		List<PkCtntItemParView> vList = new ArrayList<PkCtntItemParView>();
		for (int i = 0; i < dmList.size(); i++) {
			PickCtntItemPar dm = (PickCtntItemPar) dmList.get(i);
			PkCtntItemParView dmView = new PkCtntItemParView();
			dmView.setPickCtntItemPar(dm);
			vList.add(dmView);
		}
		
		request.setAttribute("pEntryId", pEntryId);
		return new ViewForward(forward(mapping), vList, getSelViewProps(VIEW_NAME), null, null);
	}
}
